<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>v-on的基本使用</title>
  <script src="../js/vue.min.js"></script>
</head>

<body>
  <div id ="app"> 
    <h2>{{ counter }}</h2>
    <button @click="increment()" style="width: 80px;margin-right: 10px;"> +</button>

    <button @click="decrement()" style="width: 80px;">-</button>
  </div>

  <script>
   var vm = new Vue({
    el: '#app',
    data: {
      counter: 0,
    },
    methods: {
      increment() {
        this.counter ++;
      },
      decrement() {
        this.counter --;
      }
    }
   });
  </script>
</body>

</html>